def threesum_for(nums, target):
    n = len(nums)
    loop_dict = {}
    for i in range(n):     # 三个数相加=target
        for j in range(i+1, n):
            num_3 = target - nums[i] - nums[j]
            if num_3 in loop_dict:
                return num_3, nums[i], nums[j]
            loop_dict[nums[i]] = i
            loop_dict[nums[j]] = j
 
 
print(threesum_for([2, 3, 7, 9, 4, 6], 14))
# ————————————————
# 版权声明：本文为CSDN博主「gy_98」的原创文章，遵循 CC 4.0 BY-SA 版权协议，转载请附上原文出处链接及本声明。
# 原文链接：https://blog.csdn.net/qq_42684307/article/details/90812505